package com.awenhui.demo.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.validation.Valid;
import java.time.LocalDateTime;

/**
 * @author yuxf
 * @version 1.0
 * @date 2020/5/18 16:34
 */
@Component
@Slf4j
public class TestTask {



    @Scheduled(cron = "5 0/5 * * * ?")
    public void task01()
    {
        String message= System.currentTimeMillis()+ ":"+ System.getProperty("os.name");
        System.out.println(message);
    }

    @Scheduled(fixedRate = 185000)
    public void task02()
    {
        String message= System.currentTimeMillis()+ ":"+LocalDateTime.now().getSecond();
        System.out.println(message);
    }

    @Scheduled(cron = "${timing.ten-second-execute}")
    public void task03()
    {
       log.info("从配置中取执行规则，每30s执行一次");
    }
}
